//============请求头=============
function getUsers(){
    axios.get('/my/userinfo',{
        // headers:{
        //     Authorization:localStorage.getItem('token')
        // },
    }).then(({data})=>{
        console.log(data)
        
        const name = data.data.nickname || data.data.username
        console.log(name);
        // return
        if(data.data.user_pic){
            $('.avatar').prop('src',data.data.user_pic).show()
        }else{
            $('.text-avatar-box').show()
            $('.text-avatar').html(name[0].toUpperCase())
        }
        //展示欢迎谁
        $('#welcome').text(`欢迎${name}`)
    })
}
getUsers()
//===============退出功能============
const layer = layui.layer
$('#btnLogout').click(function(){
    layer.confirm('你真的想离开我么', {icon: 3, title:'提示'}, function(index){
        localStorage.removeItem('token')
        location.href = '/login.html'
        layer.close(index);
      });
})
